package com.yibai.web.utils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

/**
 * @author  fzh
 */

public class IdUtils {

    /**
     * 获取UUID
     *
     * @return
     */
    public static String getUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }


    public static String getShartUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }


    /**
     * 生成商品编号 14位
     * @return
     */
    public synchronized static String getNum14() {
        String rabdomStr = String.valueOf((Math.random() * 9 + 1) * 1000);
        LocalDateTime ldt = LocalDateTime.now();
        String dataStr =  ldt.format(DateTimeFormatter.ofPattern("yMMdHHmmss"));
        String numStr = rabdomStr.substring(0, 4);
        numStr = dataStr + numStr;
        return numStr;
    }


    public static void main(String[] args) {
        System.out.println(getNum14());
    }
}
